<!DOCTYPE html>
<html>
<title>忘记密码</title>
<@h.head />
<body>
	<div class="container">

		<form class="definewidth m20" action="${path}/user/update_myself" id="fm"
			method="post">
			<input type="hidden" id="id" value="${id!0}" name="id">
			<table class="table table-bordered definewidth m10">
				<tr>
					<td colspan="2"><h2>设置新密码：</h2></td>
				</tr>
				<tr id="old_password">
					<td class="tableleft">原密码 <span class="required">*</span></td>
					<td><input type="password" name="oldPassword" id="old_pwd" value="" class="easyui-validatebox" required="true"
							   datatype="*6-18" nullmsg="请输入原密码！" errormsg="密码至少6个字符,最多18个字符！" />
						<span class="Validform_checktip">密码为6~18个字符</span></td>
				</tr>
				<tr id="new_password">
					<td class="tableleft">新密码 <span class="required">*</span></td>
					<td><input type="password" name="newPassword" id="new_pwd" value="" class="easyui-validatebox" required="true"
							   datatype="*8-18" nullmsg="请输入新密码！" errormsg="密码至少8个字符,最多18个字符！" />
						<span class="Validform_checktip">密码为8~18个字符</span></td>
				</tr>
				<tr id="new_password_2">
					<td class="tableleft">重输新密码 <span class="required">*</span></td>
					<td><input type="password" name="newPassword2" id="new_pwd2" value="" class="easyui-validatebox" required="true"
							   datatype="*8-18" nullmsg="请再次输入新密码！" errormsg="密码至少8个字符,最多18个字符！" validType="equalTo['#new_pwd']" invalidMessage="两次输入密码不匹配" />
						<span class="Validform_checktip">密码为8~18个字符</span></td>
				</tr>
				<tr>
					<td colspan="2">
						<button id="doSave" type="button" class="btn btn-primary">提交</button>
					</td>
				</tr>
			</table>
		</form>
	</div>
	<@h.foot />
	<script type="text/javascript">
		var callback = function(data) {
			if (data.status == "0") {
				if(confirm("密码设置成功请求重新登录")) {
				    window.location.href="${path}/index";
				};
			} else {
			    alert(data.msg);
			}
		};
        $('#doSave').click(function () {
            var url = "${path}/update-pwd";

            $.ajax({
                cache: true,
                type: "POST",
                url: url,
                data: $('#fm').serialize(),// 你的formid
//                async: false,
                error: function (request) {
                    alert("请求出问题." + request);
                },
                success: function (data) {
                    var myData = JSON.parse(data);
                    callback(myData);
                }
            });
        });
		$("#fm").validFrom();
	</script>
</body>
</html>